package com.otaku.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.otaku.AbstractDataConvertor;
import com.otaku.BaseController;
import com.otaku.domain.user.SysUsers;
import com.otaku.service.user.UserService;

@Controller
@RequestMapping("/register")
public class RegisterContoller extends BaseController{
	@Autowired
	private UserService userService;
	private final Logger logger = LoggerFactory.getLogger(getClass());
	@RequestMapping(value = "success")
	public ModelAndView register(){
		return convertData(new AbstractDataConvertor() {
            @Override
            public String getViewPath() {
            	logger.info("enter");
                return "/register/success";
            }
		});
	}
	@RequestMapping(value = "doRegister")
	public ModelAndView doRegister(final SysUsers users){
		return convertData(new AbstractDataConvertor() {
		    @Override
            public Object getData() {
		    	SysUsers user=userService.register(users);
                return user;
            }
		});
	}
}
